home *** CD-ROM | disk | FTP | other *** search
/ Digital Beauty EX: Matsuoka / Digital Beauty EX: Matsuoka.iso / pc / r3_demo / shade_r3 / pro_demo / scripts / spheres.js next >
Encoding:
JavaScript  |  1999-04-02  |  2.4 KB  |  81 lines

  1. //Shade Sample Script
  2. //
  3. //Copyright (C) 1998 ExpressionTools, Inc.
  4. //
  5. //----------------------------------------------------------------------------------------------------------------
  6.  
  7. var ok = XShade.ShowMessageBox("このサンプルは螺旋状に球を配置するスクリプトです。", true);
  8. if (ok == true) {
  9.     PutSpheres()
  10. }
  11.  
  12. //実行前のメッセージを表示させない場合は、上の記述を削除して
  13. //この下の関数の先頭についているコメント記号を消してください。
  14.  
  15. //PutSpheres();
  16.  
  17. /****** Main Function ******/
  18. function PutSpheres() {
  19.     var call_dialog1 = new Dialog1();
  20.     if (call_dialog1.can_exe1) {
  21.     
  22.         XShade.Message("実行中...");
  23.  
  24.         //画面の更新を禁止する。
  25.         XShade.InhibitUpdate();
  26.  
  27.         XShade.CreatePart();
  28.  
  29.         //球を配置していく。
  30.         for (var i = 0; i < call_dialog1.number_t; i++) {
  31.             XShade.CreateSphere(Math.cos(DegToRad(call_dialog1.rotate_s)*i)*call_dialog1.sphere_r*i, call_dialog1.sphere_r*i, Math.sin(DegToRad(call_dialog1.rotate_s)*i)*call_dialog1.sphere_r*i, call_dialog1.sphere_r);
  32.         }
  33.  
  34.         XShade.Message("終了");
  35.  
  36.         //画面の更新をする。
  37.         XShade.AllowUpdate();
  38.  
  39.         XShade.SelectParent(1);
  40.     }
  41.     else {return;} 
  42. }
  43.  
  44. //ダイアログを表示する。
  45. /****** Dialog Object1 ******/
  46. function Dialog1() {
  47.     this.sphere_r = 10.0;
  48.     this.rotate_s = 15;
  49.     this.number_t = 50;
  50.     this.can_exe1 = true;
  51.     
  52.     XShade.BeginDialog(0);// ダイアログのID番号が0以外の場合は初期設定ファイルにプロパティ値が保存される。
  53.  
  54.  
  55.     //入力ダイアログボックス内にダイアログアイテムを追加する。
  56.     XShade.AppendFloatDialogItem("球の半径"); // 識別番号は 0
  57.     XShade.AppendIntDialogItem("角度(度)"); // 識別番号は 1
  58.     XShade.AppendIntDialogItem("個数(個)"); // 識別番号は 2
  59.  
  60.  
  61.     //それぞれのダイアログアイテムのプロパティを設定する。
  62.     XShade.FloatPropertyValue(0) = this.sphere_r; // 実数入力ダイアログアイテムの初期設定
  63.     XShade.IntPropertyValue(1) = this.rotate_s; // 整数入力ダイアログアイテムの初期設定 
  64.     XShade.IntPropertyValue(2) = this.number_t; // 整数入力ダイアログアイテムの初期設定
  65.  
  66.     var ok = XShade.AskDialog(); //ダイアログボックス内のok/Cancelボタンが押されたかを識別する。
  67.     if (ok) {
  68.         this.sphere_r = XShade.FloatPropertyValue(0);
  69.         this.rotate_s = XShade.IntPropertyValue(1);
  70.         this.number_t = XShade.IntPropertyValue(2);
  71.         this.can_exe1 = true;
  72.     }
  73.     else {this.can_exe1 = false;}
  74.     XShade.EndDialog(); //ダイアログボックス用に取得したメモリを開放する。
  75. }
  76.  
  77. //角度をラジアンにする。
  78. /****** Degree To Radian ******/
  79. function DegToRad(degree) {
  80.     return degree*(Math.PI/180);
  81. }